<!DOCTYPE html>
<html lang="zh">
<head>
    <th:block th:include="include :: header('文件上传')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>附件上传</h5>
                </div>
                <div class="ibox-content">
                    <div class="form-group">
                        <label class="font-noraml" style="color: red">（上传文件会覆盖原来已有的文件，请先下载保存）</label>
                        <div class="file-loading">
                            <input id="singleFile" name="file" type="file">
                        </div>
                    </div>
                    <hr>
                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script th:inline="javascript">
    let id = [[${id}]];
    $(document).ready(function () {
        // 单图上传
        $("#singleFile").fileinput({
            uploadUrl: ctx + 'admin/record/upload',
            maxFileCount: 1,
            autoReplace: true,
            uploadExtraData: {id: id}
        }).on('fileuploaded', function (event, data, previewId, index) {
            var rsp = data.response;
            log.info("return url：" + rsp.url)
            log.info("reutrn fileName：" + rsp.fileName)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
    });
</script>
</body>
</html>
